#include<bits/stdc++.h>
using namespace std;
int l,d[1000010],v[100010],a[100010],m,p[1000010],vmax,n,t;
bool f[1000010];
void kai(){
    int cnt=0,ans=0;
    for(int i=1;i<=n;i++){
        if(v[i]>vmax&&a[i]>=0&&d[i]<=p[m]){
            if(f[p[m]]==0){
                f[p[m]]=1;
                ans++;
            } 
            cnt++;
        } 
        else if(a[i]>=0&&((float)(vmax*vmax-v[i]*v[i])/(2*a[i])+d[i]<=p[m])){
            if(f[p[m]]==0){
                f[p[m]]=1;
                ans++;
            }
            cnt++;
        } 
        else if(a[i]<0){
            for(int j=1;j<=m;j++){
                if(p[j]<=(float)((vmax*vmax-v[i]*v[i])/(2*a[i]))+d[i]&&p[j-1]>=d[i]){
                    cnt++;
                    if(f[j]==0||f[j-1]==0){
                        ans++;
                        f[j]=1;
                        f[j-1]=1;
                    }
                    break;
                }
            }
        }
    }

    cout<<cnt<<" "<<m-ans<<endl;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int i=1;i<=t;i++){
        cin>>n>>m>>l>>vmax;
        for(int j=1;j<=n;j++){
            cin>>d[j]>>v[j]>>a[j];
        }
        for(int wsx=1;wsx<=m;wsx++){
            cin>>p[wsx];
        }
        kai();
    }
    return 0;
}